@extends('admin.layout.layout')
@section('content')
<div class="col-lg-12">
    <div class="panel panel-default">
        <div class="panel-heading">
            主贴
        </div>
        <!-- /.panel-heading -->
        <div class="panel-body">
          <div class="dataTable_wrapper">
            <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
              <div class="row">
              <form action="{{url('/admin/tiezi/index')}}" method="get">
               
                
                <div class="col-sm-6">
                  <div id="dataTables-example_filter" class="dataTables_filter">
                    <label>标题:
                      <input type="search" value="@if(!empty($request['keywords'])){{$request['keywords']}}@endif" name="keywords" class="form-control input-sm" placeholder="" aria-controls="dataTables-example"></label>
                      <button  class="btn btn-primary">收索</button>
                  </div>

                </div>
                </form>
              </div>
              <div class="row">
                <div class="col-sm-12">
                  <table class="table table-striped table-bordered table-hover dataTable no-footer" id="dataTables-example" role="grid" aria-describedby="dataTables-example_info">
                    <thead>
                      <tr role="row">
                        <th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">编号</th>
                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">所属版块</th>
                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending">标题</th>
                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending">内容</th>
                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">发帖时间</th>
                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">发帖人</th>
                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending">操作</th>
                      </tr>
                    </thead>
                    <tbody>
                    @foreach($tiezi as $k=>$v)
                      <tr class="gradeA odd" role="row">
                        <td class="sorting_1 sid">{{$v->id}}</td>
                        <td>{{$v->plate_name}}</td>
                        <td>{{$v->title}}</td>
                        <td>{{rtrim(rtrim(ltrim($v->content,"<p>"),"</p>"),"</br>")}}</td>
                        <td>{{$v->ptime}}</td>
                        <td>{{$v->username}}</td>
                        <td class="center">
                        <a class="fa fa-trash-o delete">删除</a>
                        &nbsp;&nbsp;| &nbsp;&nbsp;
                        <a class="fa fa-wrench" href="{{url('/admin/tiezi/edit',['id'=>$v->id])}}">修改</a>
                        </td></tr>
                    @endforeach
                    </tbody>
                </table>
                <center>
                  {!! $tiezi->appends($request)->render() !!}
                </center>
              </div>

            </div>
          </div>
  <!-- /.table-responsive -->
        </div>
        <!-- /.panel-body -->
  </div>
  </div>
    <!-- /.panel -->
</div>

@endsection
@section('myjs')
<script type="text/javascript">
$.ajaxSetup({
  headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  }
});
  $('.delete').click(function(){
    var id=$(this).parents('tr').find('.sid').html();
    var dd = $(this);
    // alert(id);
    // 发送ajax
    $.post('/admin/tiezi/delete',{id:id},function(data){
      if(data == 1){
        // alert('成功');
        dd.parents('tr').remove();
      }else{
        alert('删除失败');
      }
      // console.log(data);
    })
    return false; 
  })
</script>
@endsection